package Servlet;

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import Logic.OperateLogic;
import Model.OperateBean;

@SuppressWarnings("serial")
public class OperateServlet extends HttpServlet{
	@Override
	public void doGet(HttpServletRequest request, HttpServletResponse response)
				throws ServletException, IOException {
		
		 response.setCharacterEncoding("utf-8");
		 response.setContentType("text/html;charset=utf-8");
		 PrintWriter out = response.getWriter();
		 String opType = request.getParameter("opType"); 
	}
		 
	    // 接收客户端浏览器的POST请求，由Service方法跳转
	@Override
	public void doPost(HttpServletRequest request, HttpServletResponse response)
	    		throws ServletException, IOException {		
		response.setCharacterEncoding("utf-8");
		response.setContentType("text/html;charset=utf-8");
		PrintWriter out = response.getWriter();
		String opType = request.getParameter("opType");
		
		if (opType.equals("addOperate")){        	        	
			 String OperateID = request.getParameter("OperateID");
			 String OperateMemberID = request.getParameter("OperateMemberID");
			 String OperateCardID = request.getParameter("OperateCardID");
			 String OperateAccountTime = request.getParameter("OperateAccountTime");
			 String OperateExpriationTime = request.getParameter("OperateExpriationTime");
			 String OperateRemaintime = request.getParameter("OperateRemainTime");
			 OperateBean operatebean = new OperateBean();
			 operatebean.setID(Integer.parseInt(OperateID));
			 operatebean.setMember_ID(Integer.parseInt(OperateMemberID));
			 operatebean.setCard_ID(Integer.parseInt(OperateCardID));
			 operatebean.setAccount_time(Integer.parseInt(OperateAccountTime));
			 operatebean.setExpriation_time(Integer.parseInt(OperateExpriationTime));
			 operatebean.setRemain_time(Integer.parseInt(OperateRemaintime));
			 //TO DO : change the time from Interger to datetime and change the datebase setting			 
			 
			 OperateLogic operatelogic = new OperateLogic();
			 operatelogic.addOperater(operatebean);

			 out.print(1);
		 }
		
	}
	        
}
